package Sort;

import org.junit.Test;

import static org.junit.Assert.assertArrayEquals;

/**
 * Description:
 * Author:    Dane
 * CreateTime:2024/8/26-上午10:01
 * Since  :   1.0
 * Version:   1.0
 */
public class SelectSortTest {

    @Test
    public void testSelectSort() {
        checkAndPrint(new int[]{5, 4, 3, 2, 1}, new int[]{1, 2, 3, 4, 5});
        checkAndPrint(new int[]{1, 2, 3, 4, 5}, new int[]{1, 2, 3, 4, 5});
        checkAndPrint(new int[]{3, 1, 4, 1, 5}, new int[]{1, 1, 3, 4, 5});
        checkAndPrint(new int[]{5, 5, 5, 5, 5}, new int[]{5, 5, 5, 5, 5});
        checkAndPrint(new int[]{2, 3, 1, 4, 5}, new int[]{1, 2, 3, 4, 5});
        checkAndPrint(new int[]{-5, -4, -3, -2, -1}, new int[]{-5, -4, -3, -2, -1});
        checkAndPrint(new int[]{1, -2, 3, -4, 5}, new int[]{-4, -2, 1, 3, 5});
        checkAndPrint(new int[]{0, 0, 0, 0, 0}, new int[]{0, 0, 0, 0, 0});
        checkAndPrint(new int[]{5, 4, 3, 2, 1, 0}, new int[]{0, 1, 2, 3, 4, 5});
    }

    private void checkAndPrint(int[] input, int[] expected) {
        int[] result = SelectSort.select2(input);
        boolean isEqual = java.util.Arrays.equals(result, expected);
        System.out.println(isEqual);
        assertArrayEquals(expected, result);
    }
}
